(function (lib, config) {
    var loadFunc = function () {
        var textAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|'), textcolorAry = config.textcolor.split('|'), imglinkAry = config.imglink.split('|'), weblinkAry = config.weblink.split('|'), identifier = config.identifier.split('|');
        identifier[0] = identifier[0] || 'dibu_tanchu';
        identifier[1] = identifier[1] || 'swt_zhongjian';
        textAry[0] = textAry[0] || '03162392999';
        textAry[1] = textAry[1] || '廊坊东大中西医结合医院在线咨询您好！';
        textAry[2] = textAry[2] || '我是廊坊东大中西医结合医院在线医师，请问有什么可以帮到您？';
        textAry[3] = textAry[3] || '廊坊东大中西医结合医院-非营利性医院，平价医疗，百姓放心用心呵护，用爱守护！';
        imglinkAry[0] = imglinkAry[0] || 'http://m.dongdayy.com/images/swt/bottom_dongda/dd_wh.jpg';
        bgcolorAry[0] = bgcolorAry[0] || '#252525';
        bgcolorAry[1] = bgcolorAry[1] || '#e2e9ed';
        bgcolorAry[2] = bgcolorAry[2] || '#e2e9ed';
        bgcolorAry[3] = bgcolorAry[3] || '#fff';
        bgcolorAry[4] = bgcolorAry[4] || '#fff';
        bgcolorAry[5] = bgcolorAry[5] || '#cc0000';
        textcolorAry[0] = textcolorAry[0] || '';
        textcolorAry[1] = textcolorAry[1] || '#fff';
        textcolorAry[2] = textcolorAry[2] || '#000';
        textcolorAry[3] = textcolorAry[3] || '#000';
        imglinkAry[1] = imglinkAry[1] || 'http://m.dongdayy.com/images/wap/invite_share.png';
        /*TODO 方法*/
        function getScrollTop() {
            var scrollTop = 0;
            if (document.documentElement && document.documentElement.scrollTop) {
                scrollTop = document.documentElement.scrollTop;
            }
            else if (document.body) {
                scrollTop = document.body.scrollTop;
            }
            return scrollTop;
        }
        function getClientHeight() {
            var clientHeight = 0;
            if (document.body.clientHeight && document.documentElement.clientHeight) {
                var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
            }
            else {
                var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
            }
            return clientHeight;
        }

        var _ua = navigator.userAgent, _ua_text = false, _position = "fixed";
        if (config.iscomapp==1 && _ua.indexOf('baiduboxapp') > -1) {
            _ua_text = true; _position = "absolute";
        }
        var strVar = [];
        strVar.push("<style type=\"text/css\">");
        strVar.push("*{ margin:0; padding:0;}");
        strVar.push("#box div{ overflow:visible;}");/*left:0; bottom:0*/
        strVar.push("#box{ display:none; position:fixed; z-index:99999999; width:100%; "+lib.util.getPosStyle(config)+"; background:" + bgcolorAry[1] + "; font-family:Microsoft YaHei; font-size:14px;}");
        strVar.push("#box a{ text-decoration:none;}");
        strVar.push("#bbb{ display:none;}");
        strVar.push(".zxswt_title{ display:block; height:40px; line-height:40px; text-indent:7px; background:#830c04; color:#fff; font-size:14px; position:relative; text-decoration: underline !important;}");
        strVar.push(".time1{ display:block; height: 2.6em; text-align:center;font-size: 12px; line-height: 2.6; color: #6c6761; text-align: center;}");
        strVar.push("#box div.zxswt_zj{ padding:0 10px 3px; display:block; width:100%; overflow:hidden;}");
        strVar.push(".zxswt_zj p{ font:14px simsun,Microsoft YaHei,arial; text-align:left; color:" + textcolorAry[2] + "; position: relative; margin-left: 3%; padding: 10px; border: 1px solid #7ebbe4; border-top-color: #b2daf0; border-radius: 12px; box-shadow: 0 3px 0 #3ea0dd, inset 0 1px 1px #fff;background-color:#c6e5fa;background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #c6e5fa), color-stop(100%, #a6d7f7));background-image: -webkit-linear-gradient(top, #c6e5fa, #a6d7f7);background-image: -moz-linear-gradient(top, #c6e5fa, #a6d7f7);background-image: -ms-linear-gradient(top, #c6e5fa, #a6d7f7);background-image: -o-linear-gradient(top, #c6e5fa, #a6d7f7);background-image: linear-gradient(top, #c6e5fa, #a6d7f7);letter-spacing: -1px; width:70%; float:left;}");
        strVar.push(".zxswt_zj p img{ width:22px; height:22px; vertical-align: bottom;}");
        strVar.push(".zxswt_zj p:before{ width:18px; height:13px; position:absolute; content:\"\"; top:-1px; left:-9px; background:url(http://m.dongdayy.com/images/swt/bottom_dongda/arrow.png) no-repeat;}");
        strVar.push(".zxswt_zj p:after{ width:40px; height:26px; content:\"\"; position:absolute; bottom:-4px; right:-7px; background:url(http://m.dongdayy.com/images/swt/bottom_dongda/wave.png) no-repeat;background-size: 40px;}");
        strVar.push(".zxswt_bot{ display:block; margin-top: 15px; text-align:center; padding: 3px 0; border-top: 1px solid #c7c7c0; border-bottom: 1px solid #979185; background-color: " + bgcolorAry[2] + " ; text-align:center; height:2em; width:100%;}");
        strVar.push(".zxswt_bot span,.zxswt_bot a{ display: inline-block; width: 23%; margin: 0 4%; border: 1px solid #a6a5a1; border-radius: 12px; background-color:" + bgcolorAry[3] + ";font-size: 16px; color: " + '#6c6761' + ";  text-align: center; text-decoration: none; transition: all .3s linear 0s; line-height:1.6em;}");
        strVar.push(".zxswt_bot a{ color:" + '#fff' + "; background:" + bgcolorAry[5] + ";}");
        strVar.push("#box2{ width:276px; height:161px; display:none; position:" + _position + "; left:50%; margin-left:-138px;margin-top:-80px; z-index:99999999;}");
        strVar.push("#box2 span{ position:absolute; right:0; top:0; width:16%; height:50px;}");
        strVar.push("#box2 a:nth-child(2){ width:276px; height:161px;}");
        strVar.push("#box2 a:nth-child(3){ width:126px; height:44px; position:absolute; left:11px; bottom:0;}");

        strVar.push("#box2 a:nth-child(4){ width:53px; height:44px; position:absolute; left:93px; bottom:16px;}");
        strVar.push("#LRdiv1,#LRdiv0{display:none!important;}");
        strVar.push(".title { background: " + bgcolorAry[0] + " ; font-size:18px; line-height: 40px;color: " + textcolorAry[1] + ";padding-left:14px;}.zixun_dh { display: block; width: 50px; height: 40px; margin-top: -40px; margin-left: 85%;color:" + '#fff' + ";}.zxswt_zj_t{ margin-left:3%; float:left; width:45px; height:45px;}");


        strVar.push("</style>");
        strVar.push("<div id=\"box\">");
        strVar.push("<div class=\"title\">" + textAry[1] + "<span class=\"zixun_dh\" href=\"javascript:void(0);\" onclick=\"toolclose();\" target=\"_self\">关闭</span></div>");
        strVar.push("<div id=\"now1\" class=\"time1\"></div>");
        strVar.push("<div class=\"zxswt_zj\">");
        strVar.push("  <img src=\"" + imglinkAry[0] + "\" class=\"zxswt_zj_t\"/>");
        strVar.push("  <p><img src=\"http://m.dongdayy.com/images/swt/bottom_dongda/smile.gif\" alt=\"smile\"> " + textAry[2] + "</p>");
        strVar.push("</div>");
        strVar.push("<div id=\"bbb\">");
        strVar.push("<div id=\"now2\" class=\"time1\"></div>");
        strVar.push("<div class=\"zxswt_zj\">");
        strVar.push("  <img src=\"" + imglinkAry[0] + "\" class=\"zxswt_zj_t\"/>");
        strVar.push("  <p style='color:" + textcolorAry[3] + ";'>" + textAry[3] + "</p>");
        strVar.push("</div>");
        strVar.push("</div>");
        strVar.push("<div class=\"zxswt_bot\">");
        strVar.push("  <span onclick=\"toolclose();\">稍后再说</span>");
        strVar.push("  <a href=\"tel:" + textAry[0] + "\" target=\"_self\" style=\"background-color:" + bgcolorAry[4] + "; color:" + '#6c6761' + ";\">电话咨询</a>");
        strVar.push("  <a href=\"javascript:void(0);\" onclick=\"openZoosUrl('" + identifier[0] + "');\">免费咨询</a>");
        strVar.push("</div>");
        strVar.push("</div>");
        strVar.push("<div id=\"box2\" style=\"top:40%\">");
        strVar.push("  <span></span>");
        strVar.push("  <a href=\"javascript:void(0);\" onclick=\"openZoosUrl('" + identifier[1] + "');\"><img src=\"" + imglinkAry[1] + "\" /></a>");
        strVar.push("  <a href=\"tel: " + textAry[0] + "\"></a>");
        strVar.push("  <a href=\"tel: " + textAry[0] + "\"></a>");
        strVar.push("</div>");
        var o = document.createElement('div');
        o.innerHTML = strVar.join('');
        while (o.firstElementChild) {
            document.body.appendChild(o.firstElementChild);
        };


        if (_ua_text) {
            var _t = document.getElementById('box2').style.top;
            window.onscroll = function () {
                document.getElementById('box2').style.top = parseInt(_t) + (getScrollTop() / getClientHeight()) * 100 + '%';
            }
        }
        setTimeout(function () {
            level();
        }, config.firsttime * 1000);
        function level() {
            var oBox = document.getElementById('box');
            var oH2 = oBox.getElementsByTagName('span')[0];
            var oBox2 = document.getElementById('box2');
            var oBox3 = document.getElementById('bbb');
            var oH22 = oBox2.getElementsByTagName('span')[0];
            oBox.style.display = 'block';
            oBox2.style.display = 'none';
            oH2.onclick = function () {
                oBox.style.display = 'none';
                setTimeout(function () {
                    document.getElementById('box2').style.display = 'block';
                }, 8000);
                oBox3.style.display = 'none';
            };
            oH22.onclick = function () {
                oBox2.style.display = 'none';
                setTimeout(function () {
                    document.getElementById('box').style.display = 'block';
                }, 8000);
                oBox3.style.display = 'none';
                setTimeout(function () {
                    document.getElementById('bbb').style.display = 'block';
                }, 13000);
            };
        }
        thisURL = document.URL;
        //商务通代码
        /*获取当前时间*/
        var now = new Date();
        var hh = now.getHours();
        var mm = now.getMinutes();
        var ss = now.getSeconds();
        var date1 = document.getElementById("now1");
        var date2 = document.getElementById("now2");
        function getDateWeek(obj) { if (obj < 10) return "0" + obj; else return obj; }
        date1.innerHTML = getDateWeek(hh) + ":" + getDateWeek(mm) + ":" + getDateWeek(ss);
        date2.innerHTML = getDateWeek(hh) + ":" + getDateWeek(mm) + ":" + getDateWeek(ss + 5);
        setTimeout(function () {
            document.getElementById('bbb').style.display = 'block';
        }, 5000);

        toolclose = function () {
            document.getElementById("box").style.display = 'none';
            setTimeout(function () {
                document.getElementById('box2').style.display = 'block'
            }, 10000);
        }
        function close_r3() {
            document.getElementById('box2').style.display = 'none';
        }


    };
    lib.load(loadFunc);/*执行代码*/
})('{{lib}}', '{{config}}');